<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue子组件ref用法</title>  
    <script src="./vue.js"></script>
</head>
<body>
    <div id="app">
        <counter ref='one'
                 @change='handleChange'
        ></counter>
        <counter ref='two'
                 @change='handleChange'
        ></counter>
        <div v-if='total'>{{total}}</div>
    </div>
    <script>
        Vue.component('counter',{
            data:function(){
                return {
                    number:0,
                    a:5
                }
            },
            template:'<div @click="hanleclick">{{number}}</div>',
            methods:{
                hanleclick:function(){
                    this.number++;
                    this.$emit('change')
                }
            }
        })
        var vm = new Vue({
            el:'#app',
            data:{
                total:0
            },
            methods:{
                handleChange:function(){
                    this.total = this.$refs.one.number + this.$refs.two.number;
                    console.log(this.$refs.one.a)
                }
            }
        })
    </script>
</body>
</html>